{% extends 'base.html' %}
{% block title %}{{ title }}{% endblock %}
{% load custom_filters %}
{% block content %}
<div class="container mt-4">
    <div class="card shadow-sm">
        <div class="card-header bg-primary text-white">
            <h5 class="mb-0"><i class="bi bi-person-gear me-2"></i>{{ title }}</h5>
        </div>
        <div class="card-body p-4">
            <form method="post">
                {% csrf_token %}
                {% for field in form %}
                <div class="mb-3">
                    <label for="{{ field.id_for_label }}" class="form-label fw-semibold text-dark">{{ field.label }}</label>
                    {% if field.errors %}<div class="invalid-feedback d-block">{{ field.errors }}</div>{% endif %}
                    {% if field.errors %}{{ field|add_class:'form-control w-100 is-invalid' }}{% else %}{{ field|add_class:'form-control w-100' }}{% endif %}<br>
                    {% if field.help_text %}
                    <small class="form-text text-muted mt-1">{{ field.help_text }}</small>
                    {% endif %}
                </div>
                {% endfor %}
                <div class="d-flex justify-content-between mt-4 gap-2">
                    <a href="{% url 'core:student_list' %}" class="btn btn-outline-secondary btn-sm">
                        <i class="bi bi-arrow-left me-2"></i>返回列表
                    </a>
                    <button type="submit" class="btn btn-primary btn-sm">
                        <i class="bi bi-save me-2"></i>添加学生
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}